package com.dragon.mmochat.message;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.model.enumType.MmochatOtherSystemSettingType;
import com.dragon.mmochat.model.role.MmochatPlayer;
import com.skymobi.buffer.SkymobiBuffer;
import com.skymobi.message.SkymobiProtocolMessage;

public class Mmochat_2_3S extends SkymobiProtocolMessage {
	MmochatPlayer role;
	MmochatPlayer me;

	public Mmochat_2_3S() {
		setMsgCode(MmochatConstant.MSGCODE_MMOCHAT_S_2_3);
	}

	@Override
	protected void encodeBody(SkymobiBuffer out) {
		out.putInt(role.getRoleId());
		out.putUnsignedInt(role.getStateValue(me));
		out.putPrefixedString(role.getName(), 2);

		if (me
				.getOtherSystemSettingByType(MmochatOtherSystemSettingType.不显示他人等级)) {
			if (role.getCurChenHao() != null) {
				out.putPrefixedString(role.getCurChenHaoInfo(), 1);
			} else {
				out.put((byte) 0);
			}
		} else {
			// 显示他人等级
			out.putPrefixedString(role.getLevelInfo(), 1);
		}

	}

	public void setRole(MmochatPlayer role) {
		this.role = role;
	}

	public void setMe(MmochatPlayer me) {
		this.me = me;
	}

}